<template>
  <div style="height: 100%;background-color:white ;padding: 5px">
    <div>
      <div style="display: inline-block">
        <el-button @click="goBack" icon="el-icon-back" type="text">返回</el-button>
      </div>
      <div style="display: inline-block">|</div>
      <div style="display: inline-block;">
        <div style="padding-bottom: 15px;">
          <span style="font-family: 'Microsoft YaHei',sans-serif;display: inline-block">日志</span>
        </div>
      </div>
      <div style="border-bottom: solid 1px #C9C9C9;"></div>
    </div>
    <div style="margin-top: 10px">
      <label> 知识名称:</label>
      <span v-html="knowledgeName"></span>
    </div>
    <el-row>
      <el-table highlight-current-row :data="logTableData" :height="tableHeight" border stripe style="width: 100%;margin-top: 10px">
        <el-table-column label="操作人" min-width="400" prop="createdBy"></el-table-column>
        <el-table-column label="操作动作" min-width="180" prop="operate">
          <template slot-scope="scope">
            {{ scope.row.operate === 0 ? '提交' : '' }}
            {{ scope.row.operate === 1 ? '审核通过' : '' }}
            {{ scope.row.operate === 2 ? '驳回' : '' }}
            {{ scope.row.operate === 3 ? '发布' : '' }}
            {{ scope.row.operate === 4 ? '新建' : '' }}
            {{ scope.row.operate === 5 ? '删除' : '' }}
            {{ scope.row.operate === 6 ? '重新编辑' : '' }}
            {{ scope.row.operate === 7 ? '恢复' : '' }}
            {{ scope.row.operate === 8 ? '勘误' : '' }}
          </template>
        </el-table-column>
        <el-table-column label="操作结果" min-width="100" prop="oresult">
          <template slot-scope="scope">
            {{ scope.row.oresult === 0 ? '成功' : '' }}
            {{ scope.row.oresult === 1 ? '失败' : '' }}
          </template>
        </el-table-column>
        <el-table-column :formatter="dateFormat" label="记录时间" min-width="150" prop="updatedTime">
        </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>

<script>
import moment from "moment";

export default {
  name: "FlowChartLog",
  data() {
    return {
      knowledgeName: '',
      logTableData: '',
      tableHeight: '',
    }
  },
  methods: {
    dateFormat: function (row, column) {
      const date = row[column.property]
      if (date == undefined) {
        return ''
      }
      return moment(date).format("YYYY-MM-DD  HH:mm:ss")
    },
    goBack: function () {
      this.$router.go(-1)
    },
  },
  created() {
    this.axios.get('/pmph/action/flowChartAction/selectHistoryById', {
      params: {
        id: this.$route.query.id
      }
    }).then((response) => {
      console.log(response)
      this.logTableData = response.data;
      this.knowledgeName = response.data[0].knowledgeName;

    }).catch((error) => {
      console.error(error);
      this.logTableData = [];
      this.noData = true;
      this.$message.error("未能请求到数据");
    })
    this.tableHeight = CONST.WORKSPACE_HEIGHT - 160 + "px"
  }
}
</script>

<style scoped>

</style>
